package org.apache.ibatis.demo;


import org.apache.ibatis.demo.entity.Blog;
import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;

import java.io.IOException;
import java.io.InputStream;

/**
 * @fileName: Test
 * @author: zengqf3
 * @date: 2021/3/11 20:32
 * @description:
 */

public class Test {

    public static void main(String[] args) throws IOException {
        String resource = "mybatis-config.xml";
        InputStream inputStream = Resources.getResourceAsStream(resource);
        SqlSessionFactory sqlSessionFactory = new SqlSessionFactoryBuilder().build(inputStream);

        SqlSession sqlSession = sqlSessionFactory.openSession();
//        Blog blog = new Blog(1, "小明", "学mybatis");
        Object o = sqlSession.selectOne("org.apache.ibatis.demo.mapper.BlogMaper.selectById", 1);
        System.out.println(o);
    }
}
